﻿
/// <reference path="jquery-1.3.2.js" />
document.write(' <div style="display:none;" id="UserFeedDiv">');
document.write( '<iframe class="opacity-ifr" frameborder="0" height="0"></iframe>');
document.write( '<div class="opacity-bg"></div>');
document.write( '<!-- S 说说弹层 --> ');
document.write( '<div id="layer-box1" class="layer-box"> <b class="layer-top"></b> <a class="layer-close" href="javascript:void(0)" title="关闭"></a>');
document.write( '<div class="box-con">');
document.write( ' <div class="send_poster clear">');
document.write('  <div class="title_area clear">');
document.write('  <div class="title"></div>');
document.write( ' <div class="num" id="txtLen" style="display:none">还可输入<span>140</span>字</div>                   ');
document.write( '</div>');
document.write( '<div class="shadow">');
document.write( '   <div class="input">');
document.write( '       <textarea    id="UserBackContent" name="UserBackContent"  class="input_detail">欢迎提出宝贵的意见和建议。我们会认真阅读并及时回复，你的支持是对我们最大的鼓励和帮助。</textarea>');
document.write( ' </div>');
document.write( ' </div>');
document.write( ' <div class="feekback_area">');
document.write( '    <div class="addimg">');
document.write( '    <div class="hsaddbg">');
document.write( '   <span class="hsaddbtn" id="uploadButtonPlaceHolder"></span>');
document.write( '   </div>');
document.write( ' </div>');
document.write( '   <ul id="fa_img_list" class="img_list">');                        
document.write( '  </ul>');
document.write( '  <div class="user_info clear">');
document.write( '    <dl class="clear">');
document.write( '    <dt >联系方式:</dt>');
document.write( '    <dd>');
document.write( '    	<div class="shadow">');
document.write('       	<input type="text" value="" class="email" id="UserBackemail" maxlength="30" name="UserBackemail"/><div style="float: right; margin-top: 5px;width:180px;" id="UserBackemailError"></div>');
document.write( '       </div>');
document.write( '    </dd>');
document.write( ' </dl>');
document.write( ' <dl class="clear">');
document.write('    <dt>姓&nbsp;&nbsp;&nbsp;&nbsp;名:</dt>');
document.write( '  <dd>');
document.write( '	<div class="shadow">');
document.write('   	<input type="text"  class="username" name="UserBackusername" maxlength="20" id="UserBackusername"/><div style="float: right;margin-top: 5px; width:180px;" id="UserBackusernameError" ></div>');
document.write( '     </div>');
document.write( ' </dd>');
document.write( '</dl>');
document.write(' <div id="feek_btn" class="feek_btn fr feedcursor"><a href="javascript:void(0)" id="UserBacksubbtn" >提交</a></div>');
document.write( '</div>');
document.write( '</div>');
document.write( '</div>');
document.write( ' </div>');
document.write( ' <b class="layer-btm"></b>');
document.write( ' </div>');
document.write( '<!-- E 说说弹层 --> ');
document.write( '<!--thank弹出--> ');
document.write( '   <div id="layer-box2" class="layer-box" style="display:none">');
document.write( '<b class="layer-top"></b> <a class="layer-close" href="javascript:void(0)"  id="layer-close" title="关闭"></a>');
document.write( '<div class="box-con">');
document.write( '      <div class="thank_poster clear">');
document.write( '          <div class="title_area clear">');
document.write( '             <div class="title01"></div> ');
document.write( '         </div>');
document.write( '      <div class="thank_suggestion">');
document.write('          <h4>');
var arrayObj = new Array();
arrayObj = people.split('');
for (var i = 0; i < arrayObj.length; i++) {
    document.write("<span>"+arrayObj[i]+"</span>");
}
document.write('&nbsp;&nbsp;乐途达人，每天结识新的朋友&nbsp;&nbsp;');
document.write('    <a href="javascript:void(0)" id=\"userFeedLogon\" >登录/注册</a>');
document.write( '    </h4>');
document.write( '    <p class="footprint"></p>');
document.write( '    <p class="footprint-btn"><a href="http://my.lotour.com/passport/external/jump.aspx?t=1" target="_blank">留足迹&gt;&gt;</a></p>');
document.write( '  </div>');
document.write( '</div>');
document.write( '</div>');
document.write( ' <b class="layer-btm"></b> </div>');
document.write('</div>');

document.write( '<!--[if IE 6]>');
document.write('<script type="text/javascript" src="http://js.lotour.com/im/DD_belatedPNG.js"></script>');
document.write('<script type="text/javascript">');
document.write(' setTimeout("initDD_belatedPNG()", 500);');
document.write( '</script>');
document.write( '<![endif]-->');

document.write('<script type="text/javascript" src="http://js.lotour.com/im/swfupload.js"></script>');
document.write('<script type="text/javascript" src="http://js.lotour.com/im/uploadphoto.js"></script>');
document.write('<link href="http://css.lotour.com/im/floatposter.css" rel="stylesheet" type="text/css" />');


 

//删除上传的图片
function delimg(t) {
    $(t).parents('li').remove();
}
function initDD_belatedPNG() {
    DD_belatedPNG.fix('.onlinefeed-btn,.serbtn,.feedonline');
}
function userFeedButtonHidden() {
    $("#UserFeedButton").hide();
}
//点击展开控制器
function UserBackControl() {

    //$("#UserFeedButton").hide();
    $("#onlinefeed-btn").toggle(function () {
        $(".onlinefeed-list").animate({ width: 243 }, 50);
        $(".onlinefeed").animate({ width: 245 }, 50).css("overflow", "visible");
        $(".onlinefeed-inner").animate({ width: 243 }, 50);
      //  $("#UserFeedButton").show();
       
        $(".onlinefeed-btn").css("background-position", "9px -12px")
    }, function () {
        $(".onlinefeed-list").animate({ width: 138 }, 50);
        $(".onlinefeed").animate({ width: 140 }, 50).css("overflow", "visible");
        $(".onlinefeed-inner").animate({ width: 138 }, 50);
      //  $("#UserFeedButton").hide();
        $(".onlinefeed-btn").css("background-position", "9px 12px")
    });
    $("#online").live("click", function () {

        if ($("#online-chat").is(":hidden")) {
        
            $("#online-chat").show();
            var st = $(document).scrollTop();
            if (st > 0) {
                $(".gotop").hide();
            }
        }
        else {
         
            $("#online-chat").hide();
            var st = $(document).scrollTop();
            if (st > 0) {
                $(".gotop").show();
            }
        }
    })

    //返回顶部
    var $backToTopTxt = "", $backToTopEle = $('<a title="回到顶部" class="gotop"></a>').appendTo($("body")).text($backToTopTxt).attr("title", $backToTopTxt).click(function () { $("html, body").animate({ scrollTop: 0 }, 120); }), $backToTopFun = function () {
        //判断qq是否隐藏
        var MSNStatus = $("#online-chat").is(":hidden");
        //如果隐藏并且 滚动条大于0 就显示 MSN覆层
        var st = $(document).scrollTop(), winh = $(window).height(); (st > 0 && MSNStatus==true) ? $backToTopEle.show() : $backToTopEle.hide();

        //IE6下的定位
        if (!window.XMLHttpRequest) {

            $backToTopEle.css("top", st + winh - 96);
          // $("div.onlinefeed").css("top", st + winh - 35);
        }
    };
    $(window).bind("scroll", $backToTopFun);
    $(function () { $backToTopFun(); });
}
$(document).ready(function () {
    InitUploadComponent();
    UserBackIsLogon();
    setTimeout("OnlineShow()", 500);
    setTimeout("UserBackControl()", 500);
    setTimeout("ClickFeedDivShow()", 500);
    setTimeout("UserFeedBackPost()", 500);

    $('#UserBackContent').val("欢迎提出宝贵的意见和建议。我们会认真阅读并及时回复，你的支持是对我们最大的鼓励和帮助。");

    $("#UserBackContent").bind({
        "keyup": function (e) {
            checkWords($(this).val());
        }
    });

    $("#UserBackContent").focus(function () {
        $('.title_area .num').show();
        $('.func_area .func a').addClass('on');
        var len = smartLen($(this).val());
        if ($('#UserBackContent').val() == "欢迎提出宝贵的意见和建议。我们会认真阅读并及时回复，你的支持是对我们最大的鼓励和帮助。") {
            $('#UserBackContent').val("");
        }
        if (len < 140) {
            $('#feek_btn').addClass('on');
            $('#feek_btn').removeClass('feedcursor');
        }
        else {
            $('#feek_btn').removeClass('on');
            $('#feek_btn').addClass('feedcursor');
        }
    })

    $("#UserBackemail").blur(function () {

        if (!UserFeedCheckEmail() && !UserFeedCheckPhone() && !UserFeedCheckTel()) {
            $("#UserBackemailError").html("您可以添加邮箱、手机、固定电话");
            return false;
        }
        else {
            $("#UserBackemailError").html("");
            return true;
        }

    })

    $("#UserBackusername").blur(function () {

        if (!UserFeedCheckName()) {
            $("#UserBackusernameError").html("请填写真实姓名");
            return false;
        }
        else {
            $("#UserBackusernameError").html("");
            return true;
        }

    })

    $("#userFeedLogon").live("click", function () {
        $("#layer-box1").show();
        $("#layer-box2").hide();
        $("#UserFeedDiv").hide();
        $.getScript("http://js.lotour.com/login/floatlogin_v2.js", function () {
            PLoginReg.prototype.regCallBack = null;
            PLoginReg.prototype.loginCallBack = null;
            PLoginReg.prototype.showLogin(1, 1);
        });

    })
    //点击留足迹 覆层关闭
    $(".footprint-btn a").live("click", function () {
        $("#layer-box1").show();
        $("#layer-box2").hide();
        $("#UserFeedDiv").hide();
    })
    $("#UserBackContent").blur(function () {

        if ($('#UserBackContent').val() == "") {
            $('#UserBackContent').val("欢迎提出宝贵的意见和建议。我们会认真阅读并及时回复，你的支持是对我们最大的鼓励和帮助。");
            $('#feek_btn').removeClass('on');
            $('#feek_btn').addClass('feedcursor');
            $('.title_area .num').hide();
        }
    })

})
//如果QQ MSN有内容 就显示覆层
function OnlineShow() {

    var num = parseInt($("#online-chat").find("dl").length);
    if (num > 0) {
        $("#online-chat").show();
        $(".gotop").hide();
    }

}

///姓名
function UserFeedCheckName() {
   var reg = /^[\u4e00-\u9fa5]*$/;
   var pattern= /^[A-Za-z]+$/;
   if ($.trim($("#UserBackusername").val()) != "" && !reg.test($.trim($("#UserBackusername").val()))) {
       $("#UserBackusernameError").html("请填写真实姓名");
       return false;
   }
   else {
       $("#UserBackusernameError").html("");
       return true;
   }
}
//手机
function UserFeedCheckPhone() {

    var patrn = /^1[3458]\d{9}$/;
    if ($.trim($("#UserBackemail").val()) != "" && !patrn.test($("#UserBackemail").val())) {
        $("#UserBackemailError").html("您可以添加邮箱、手机、固定电话");      
        return false;
    }
    else {
        $("#UserBackemailError").html("");
        return true;
    }
}
///电话
function UserFeedCheckTel() {
    var patrn = /^(\(\d{3,4}\)|\d{3,4}-)?\d{7,8}([-|转]\d{1,4})?$/;
    if ($.trim($("#UserBackemail").val()) != "" && !patrn.test($("#UserBackemail").val())) {
        $("#UserBackemailError").html("您可以添加邮箱、手机、固定电话");
        return false;
    }
    else {
        $("#UserBackemailError").html("");
        return true;
    }
}

//email
function UserFeedCheckEmail() {
    var patrn = /^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
    if ($.trim($("#UserBackemail").val()) != "" && !patrn.test($("#UserBackemail").val())) {
        $("#UserBackemailError").html("您可以添加邮箱、手机、固定电话");
        return false;
    }
    else {
        $("#UserBackemailError").html("");
        return true;
    }

}
//反馈提交
function UserFeedBackPost() {

    $('#feek_btn').live("click", function () {
        if ($("#feek_btn").hasClass("feedcursor")) {
            return;
        }
        var UserBackContent = $('#UserBackContent').val();
        var UserBackemail = $('#UserBackemail').val();
        var UserBackusername = $('#UserBackusername').val();

        var contentLen = smartLen(UserBackContent);
        if (contentLen < 0 || UserBackContent == "欢迎提出宝贵的意见和建议。我们会认真阅读并及时回复，你的支持是对我们最大的鼓励和帮助。") {
            alert("请输入内容");
            return false;
        }
        else if (contentLen > 140) {
            alert("超出范围");
            return false;
        }

        if (!UserFeedCheckEmail() && !UserFeedCheckPhone() && !UserFeedCheckTel()) {
            $("#UserBackemailError").html("您可以添加邮箱、手机、固定电话");
            return false;
        }

        if (!UserFeedCheckName()) {
            $("#UserBackusernameError").html("请填写真实姓名");
            return false;
        }
        var imglist = $("#fa_img_list li").find("img");

        var v_urls = "";

        $.each(imglist, function (i) {
            var pos = imglist[i].src.lastIndexOf("/") * 1;
            v_urls += imglist[i].src.substring(pos + 1).replace(",", "") + ",";
        });
        if (v_urls.length > 0) { v_urls = v_urls.substring(0, v_urls.length - 1) }
        $.getJSON("http://member.lotour.com/manage/Forms/UserFeedData.ashx", "action=userBack&BackContent=" + encodeURIComponent(UserBackContent) + "&userEmail=" + encodeURIComponent(UserBackemail) + "&userName=" + encodeURIComponent(UserBackusername) + "&v_urls=" + encodeURIComponent(v_urls) + "&callback=?", function (data) {
            if (data.status == "OK") {
                $('#layer-box1').hide();
                $('#layer-box2').show()
                ClearUserBackInput();
            }
            else {
                alert("留言失败，请稍后重试或者选择高版本的浏览器!");
            }
        })
    })

}
function ClearUserBackInput() {
    $("#UserBackContent").val("欢迎提出宝贵的意见和建议。我们会认真阅读并及时回复，你的支持是对我们最大的鼓励和帮助。");
    $("#fa_img_list").html("");
    $("#UserBackemail").val("");
    $("#UserBackusername").val("");
    $("#UserBackemailError").html("");
    $("#UserBackusernameError").html("");
    $("#feek_btn").addClass("feedcursor");
    $('#txtLen').html('还可输入<span>140</span>字');
    $('#txtLen').hide();

}
function UserBackIsLogon() {

    $.getJSON('http://my.lotour.com/user/external/userlogin.aspx?islogin=' + (new Date()) + '&callback=?',
        function (data) {
            if (parseInt(data.uid) > 0) {
                $('.thank_suggestion h4').find('a').hide();
            }
            else {
                $('.thank_suggestion h4').find('a').show();
            }
        });
}
    var urlReg = {
        "urlRegText": "((news|telnet|nttp|file|http|ftp|https)://){1}(([-A-Za-z0-9]+(\\.[-A-Za-z0-9]+)*(\\.[-A-Za-z]{2,5}))|([0-9]{1,3}(\\.[0-9]{1,3}){3}))(:[0-9]*)?(/[-A-Za-z0-9_\\$\\.\\+\\!\\*\\(\\),;:@&=\\?/~\\#\\%]*)*"
    };
    // 字符串长度  
    function smartLen(str) {
        str = str.replace(/(^[\s\n]+)|([\s\n]+$)/, "").replace(/[\s\n]+/g, " ");
        str = str.replace(new RegExp(urlReg.urlRegText, "gi"), new Array(12).join("aa"));
        return Math.ceil(($.trim(str.replace(/[^\u0000-\u00ff]/g, "aa")).length) / 2);
    }
    function checkWords(content) {
        var len = 140 - smartLen(content);
        if (len < 0) {
            $('#txtLen').html('超出&nbsp;<em style="color:#E56C0A">' + (-len) + '</em>&nbsp;字');
            $("#feek_btn").removeClass("on");
            $('#feek_btn').addClass('feedcursor');
        } else {
            $('#txtLen').html('还可输入<span>' + len + '</span>字');
            $("#feek_btn").addClass("on");
            $('#feek_btn').removeClass('feedcursor');
        }
    }
    function ClickFeedDivShow() {
        $('#UserFeedButton').live("click", function () {
            if ($('#UserFeedDiv').is(':hidden')) {
                displayFloatFeed('', '', '', ''); //displayFloat($(this), 'divlogin', -15, 171); //displayFloat1();
               // displayFloatExecID = window.setInterval("displayFloat('','','','')", 50);
            }
            else { $('#UserFeedDiv').hide(200); }
        });
        $(".layer-close").click(function () {
            $('#UserFeedDiv').hide(200);
            window.clearInterval(displayFloatExecID);
        });
        $("#layer-close").live("click", function () {
            $('#layer-box2').hide();
        })
    }

    var displayFloatExecID = '';
    function displayFloatFeed(objId, entity, n, num) {
        /*S 赵振兴:弹出登录框,添加 20120911 S*/
        $('#UserFeedDiv .layer-box').css({
            position: 'absolute',
            left: $('#UserFeedDiv').left - 171,
            top: $(window).height() / 2 + $(document).scrollTop()
        });
        $('#UserFeedDiv .opacity-bg').css({ height: $(document).height() });
        $('#UserFeedDiv').show();
        if ($('#UserFeedDiv #layer-box2').css('display') == 'block') {
            $('#UserFeedDiv #layer-box1').hide();
        } else {
            $('#UserFeedDiv #layer-box1').show();
        }

    }